package com.khoayang.littlefighterchaos.game;

import java.util.ArrayList;

import org.w3c.dom.Node;

import android.content.Context;

public class AttackingSkill extends BaseSkill{
	public AttackingSkill(Context context) {
		super(context);
	}

	private int _AttackPoint;
	private int _MPUse;
	private boolean _IsSpecial;
	private ArrayList<AttackingObject> _AttackingObjects;
	private String _BeHitActionName;


	@Override
	public void readSpecificAttributeSkill(Node node) {
		String nodeName = node.getNodeName();
		if(nodeName.compareTo("AttackPoint") == 0){
			set_AttackPoint(Integer.parseInt(node.getTextContent()));
		}else if(nodeName.compareTo("MPUse") == 0){
			set_MPUse(Integer.parseInt(node.getTextContent()));
		}else if(nodeName.compareTo("IsSpecial") == 0){
			int isSpecial = Integer.parseInt(node.getTextContent());
			if(isSpecial == 0){
				set_IsSpecial(false);
			}else{
				set_IsSpecial(true);
			}
		}else if(nodeName.compareTo("AttackingObjects") == 0){
			_AttackingObjects = getAttackingObjects(node);
		}else if(nodeName.compareTo("BeHitActionName") == 0){
			_BeHitActionName = node.getTextContent();
		}
	}

	private ArrayList<AttackingObject> getAttackingObjects(Node node) {
		ArrayList<AttackingObject> attackingObjects = new ArrayList<AttackingObject>();
		for(int i=0; i<node.getChildNodes().getLength(); i++){
			Node nodeTemp = node.getChildNodes().item(i);
			String nodeName = nodeTemp.getNodeName();
			if(nodeName.compareTo("AttackingObject") == 0){
				AttackingObject attackingObject = new AttackingObject();
				attackingObject.readFromXMLNode(nodeTemp);	
				attackingObjects.add(attackingObject);
			}
		}
		return attackingObjects;
	}

	public int get_AttackPoint() {
		return _AttackPoint;
	}

	public void set_AttackPoint(int _AttackPoint) {
		this._AttackPoint = _AttackPoint;
	}

	public int get_MPUse() {
		return _MPUse;
	}

	public void set_MPUse(int _MPUse) {
		this._MPUse = _MPUse;
	}

	public boolean is_IsSpecial() {
		return _IsSpecial;
	}

	public void set_IsSpecial(boolean _IsSpecial) {
		this._IsSpecial = _IsSpecial;
	}

	public ArrayList<AttackingObject> get_AttackingObjects() {
		ArrayList<AttackingObject> attackingObjects = new ArrayList<AttackingObject>();
		if(_AttackingObjects == null)
			return attackingObjects;
		for(int i=0; i<_AttackingObjects.size(); i++){
			AttackingObject attackingObject = _AttackingObjects.get(i).clone();
			attackingObjects.add(attackingObject);
		}
		return attackingObjects;
	}

	public void set_AttackingObjects(ArrayList<AttackingObject> _AttackingObjects) {
		this._AttackingObjects = _AttackingObjects;
	}

	public String get_BeHitActionName() {
		return _BeHitActionName;
	}

	public void set_BeHitActionName(String _BeHitActionName) {
		this._BeHitActionName = _BeHitActionName;
	}
}
